#include <iostream>
#include <Windows.h>
#include "ac_def.h"
#include "ac_behavior_tree.h"
#include "ac_behavior_script.h"

using namespace acoral;

int main()
{
	sint32 g_n1 = 0;
	BTNode* root = new BTNode(NULL);
	root->SetName("root");
	root->AddExcuteScript(new BTSeletor(root));

	BTNode* child1 = new BTNode(root);
	BTNode* child3 = new BTNode(root);
	root->AddChild(child1);
	root->AddChild(child3);

	child1->SetName("child1");
	child1->AddEvaluateScript(new BTEvalChild1(child1));
	child1->AddEnterScript(new BTEntChild1(child1));
	child1->AddExcuteScript(new BTExeChild1(child1));
	child1->AddExitScript(new BTExiChild1(child1));

	child3->SetName("child3");
	child3->AddEvaluateScript(new BTEvalChild3(child3));
	child3->AddExcuteScript(new BTSeletor(child3));

	BTNode* child2 = new BTNode(child3);
	child3->AddChild(child2);
	child2->SetName("child2");
	child2->AddEnterScript(new BTEntChild2(child2));
	child2->AddExcuteScript(new BTExeChild2(child2));
	child2->AddExitScript(new BTExiChild2(child2));

	while(true)
	{
		if(root->Evaluate(&g_n1))
			root->Excute(&g_n1);

		Sleep(1000);
	}
	return 0;
}

